<template>
	<div class="comment-form">
		<textarea v-model="content"></textarea>
		<button @click="submit">提交</button>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				content: '',
				userId: 0
			}
		},
		props: {
			moveId: {
				type: String
			}
		},
		methods: {
			getUserId() {
			  this.userId =	uni.getStorageSync('userInfo')
			},
			submit() {
				this.getUserId()
				this.$ajax.post('/film/post/save', {
					postValue: this.content,
					filmId: this.moveId,
					inputUserId: this.userId 
				}).then(res => {})
					console.log(res);
					if (res.code === 0) {
						// 提交成功，清空输入框并刷新评论列表
						this.content = ''
						this.$emit('submit')
					} else {
						// 提交失败，提示错误信息
						this.$toast(res.msg)
					}

				
			}
		}
	}
</script>

<style>
	textarea{
		border: 1px solid black;
		margin-bottom: 15rpx;
	}
</style>